package com.jy.appmarket.screenlock.widget.dialog;

import com.jy.appmarket.R;

import android.app.Dialog;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

//import com.appssuper.toolbox.R;

/** 
 * 类说明：   
 * @author  jie.li
 * @date    2015-4-10
 * @version 1.0
 */
public class SpecialSettingDialog extends Dialog implements android.view.View.OnClickListener {

	private TextView mTitleTv;
	private TextView mContentTv;
	private TextView mRedContentTv,mContentCenter;
	private Button mCancelBtn;
	private Button mConfirmBtn;
	private String mConfirmName,mCancelName;

	private SpecialDialogListener mListener;

	public interface SpecialDialogListener {
		void onConfirm();
	}

	public SpecialSettingDialog(Context context,String confirmName, String cancelName) {
		super(context, R.style.custom_dialog_theme);
		mConfirmName = confirmName;
		mCancelName = cancelName;
		init(context);
	}

	private void init(Context context) {
		setContentView(R.layout.custom_dialog);
		mTitleTv = findViewById(R.id.custom_dialog_title_tv);
		mContentTv = findViewById(R.id.custom_dialog_content_tv);
		mRedContentTv = findViewById(R.id.custom_dialog_red_content_tv);
		mContentCenter = findViewById(R.id.custom_dialog_content_ccenter_tv);
		mConfirmBtn = findViewById(R.id.custom_dialog_cancel_btn);
		mCancelBtn = findViewById(R.id.custom_dialog_confirm_btn);
		
		mConfirmBtn.setText(TextUtils.isEmpty(mConfirmName) ? context.getString(R.string.confirm) : mConfirmName);
		mCancelBtn.setText(TextUtils.isEmpty(mCancelName) ? context.getString(R.string.cancel) : mCancelName);
		
		mCancelBtn.setOnClickListener(this);
		mConfirmBtn.setOnClickListener(this);
	}

	public SpecialSettingDialog setTitle(String title) {
		mTitleTv.setText(title);
		return this;
	}

	public SpecialSettingDialog setContent(String content) {
		mContentTv.setVisibility(View.VISIBLE);
		mContentTv.setText(content);
		return this;
	}
	
	public SpecialSettingDialog setRedContent(String redcontent) {
		mRedContentTv.setVisibility(View.VISIBLE);
		mRedContentTv.setText(redcontent);
		return this;
	}
	
	public SpecialSettingDialog setContentCenter(String content){
		mContentCenter.setVisibility(View.VISIBLE);
		mContentCenter.setText(content);
		return this;
	}

	public SpecialSettingDialog setListener(SpecialDialogListener l) {
		mListener = l;
		return this;
	}
	
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.custom_dialog_cancel_btn:
			if (mListener != null) {
				mListener.onConfirm();
			}
			dismiss();
			break;
		case R.id.custom_dialog_confirm_btn:
			dismiss();
			break;
		}
	}

}
